﻿using DotNetCommon.Extensions;
using NUnit.Framework;
using Shouldly;
using System.Numerics;

namespace DotNetCommon.Test.Extensions
{
    [TestFixture]
    internal sealed class ArrayExtensions
    {
        [Test]
        public void TestCircle()
        {
            new Vector2[] { new(0, 0), new(1, 0), new(1, 1) }.Next(2).ShouldBe(new(0, 0));
            new Vector2[] { new(0, 0), new(1, 0), new(1, 1) }.Next(0).ShouldBe(new(1, 0));
            new Vector2[] { new(0, 0), new(1, 0), new(1, 1) }.Pre(2).ShouldBe(new(1, 0));
            new Vector2[] { new(0, 0), new(1, 0), new(1, 1) }.Pre(0).ShouldBe(new(1, 1));
        }

        [Test]
        public void TestReverse()
        {
            new int[] { 1, 2, 3, 4 }.ReverseFluent().ShouldBe(new int[] { 4, 3, 2, 1 });
        }

        [Test]
        public void TestReSetStart()
        {
            new int[] { 1, 2, 3, 4 }.ReSetStart(2).ShouldBe(new int[] { 3, 4, 1, 2 });
            new int[] { 1, 2, 3, 4 }.ReSetStart(2, true).ShouldBe(new int[] { 3, 2, 1, 4 });
            new int[] { 1, 2, 3, 4 }.ReSetStart(-1).ShouldBe(new int[] { 4, 1, 2, 3 });
        }
    }
}
